//
//  SAMyAccountInfoCell.m
//  yidiantong
//
//  Created by 黄志刚 on 2020/10/9.
//

#import "SAMyAccountInfoCell.h"

@interface SAMyAccountInfoCell ()

@property (nonatomic, strong) UILabel *titleLab;
@property (nonatomic, strong) UILabel *infoLab;
@property (nonatomic, strong) UIView *lineView;
@property (nonatomic, strong) UILabel *redLab;

@end

@implementation SAMyAccountInfoCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self initUI];
    }
    return self;
}

- (void)refreshCellWithTitle:(NSString *)title info:(NSString *)info {
    self.titleLab.text = title;
    self.infoLab.text = info;
    if ([title isEqualToString:@"手机"] || [title isEqualToString:@"姓名"]) {
        self.redLab.hidden = NO;
    }else {
        self.redLab.hidden = YES;
    }
}

#pragma mark - initUI

- (void)initUI {

    [self.contentView addSubview:self.titleLab];
    [self.contentView addSubview:self.redLab];
    [self.contentView addSubview:self.infoLab];
    [self.contentView addSubview:self.lineView];
    
    [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(30);
        make.centerY.mas_equalTo(0);
    }];
    
    [self.redLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.titleLab.mas_left);
        make.centerY.mas_equalTo(0);
    }];
    
    [self.infoLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-30);
        make.centerY.mas_equalTo(0);
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.right.mas_equalTo(0);
        make.height.mas_equalTo(1);
    }];
}

#pragma mark - lazy init

- (UILabel *)titleLab {
    if (!_titleLab) {
        _titleLab = [[UILabel alloc] init];
        _titleLab.font = [UIFont systemFontOfSize:16];
        _titleLab.textColor = kBlackColor;
    }
    return _titleLab;
}

- (UILabel *)redLab {
    if (!_redLab) {
        _redLab = [[UILabel alloc] init];
        _redLab.font = [UIFont systemFontOfSize:16];
        _redLab.textColor = [UIColor redColor];
        _redLab.text = @"*";
    }
    return _redLab;
}

- (UILabel *)infoLab {
    if (!_infoLab) {
        _infoLab = [[UILabel alloc] init];
        _infoLab.font = [UIFont systemFontOfSize:16];
        _infoLab.textColor = kLightgGrayColor;
    }
    return _infoLab;
}

- (UIView *)lineView {
    if (!_lineView) {
        _lineView = [[UIView alloc] init];
        _lineView.backgroundColor = kLineColor;
    }
    return _lineView;
}

@end
